<!--
  Copyright 2015-2019 the original author or authors.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<div style="position: relative; min-height: 100px;">
  <div ng-include src="'template/gt-http-error-overlay.html'"></div>
  <div gt-spinner
       gt-show="showSpinner && !showServiceCalls"
       class="gt-left-aligned-spinner">
  </div>
  <div style="position: absolute; width: 100%; margin-top: 50px;">
    <div gt-spinner
         gt-show="showSpinner && showServiceCalls">
    </div>
  </div>
  <div class="gt-panel-overlay"
       ng-if="showSpinner">
  </div>
  <div ng-if="!showSpinner && !showServiceCalls && !httpError"
       style="display: table; width: 100%; height: 100%; margin-top: 50px;">
    <div style="display: table-cell; text-align: center; vertical-align: middle;">
      <div class="gt-chart-no-data"
           ng-hide="showOverwrittenMessage">
        No data for this time period
      </div>
      <div class="gt-chart-no-data"
           ng-if="showOverwrittenMessage">
        There was service call data but it has expired
      </div>
    </div>
  </div>
  <div ng-if="showServiceCalls">
    <table class="table gt-query-table"
           style="table-layout: fixed;">
      <thead>
      <tr>
        <th style="vertical-align: middle;">
          <select class="custom-select"
                  ng-model="type"
                  style="width: inherit;"
                  ng-if="types.length > 1">
            <option selected value="">(All)</option>
            <option ng-repeat="type in types" ng-value="type">{{type}}</option>
          </select>
        </th>
        <th scope="col"
            ng-attr-aria-sort="{{ngAttrAriaSort('total-time')}}"
            class="gt-query-total-column">
          <a ng-href="{{currentTabUrl()}}{{sortQueryString('total-time')}}" class="gt-sortable-table-header">
            Total<br>
            time<br>
            <span ng-class="sortIconClass('total-time')"
                  ng-if="sortAttribute === 'total-time'">
            </span>
            (ms)
          </a>
        </th>
        <th scope="col"
            ng-attr-aria-sort="{{ngAttrAriaSort('execution-count')}}"
            class="gt-query-count-column">
          <a ng-href="{{currentTabUrl()}}{{sortQueryString('execution-count')}}" class="gt-sortable-table-header">
            Total<br>
            <span ng-class="sortIconClass('execution-count')"
                  ng-if="sortAttribute === 'execution-count'">
            </span>
            count
          </a>
        </th>
        <th scope="col"
            ng-attr-aria-sort="{{ngAttrAriaSort('time-per-execution')}}"
            class="gt-query-other-column">
          <a ng-href="{{currentTabUrl()}}{{sortQueryString('time-per-execution')}}" class="gt-sortable-table-header">
            Avg<br>
            time<br>
            <span ng-class="sortIconClass('time-per-execution')"
                  ng-if="sortAttribute === 'time-per-execution'">
            </span>
            (ms)
          </a>
        </th>
      </tr>
      </thead>
      <tbody>
      <tr ng-repeat="serviceCall in serviceCalls | filter:{type: type} | orderBy:sortAttr:sortAsc">
        <th scope="row"
            class="gt-monospace gt-break-word"
            style="font-weight: normal;">
          {{serviceCall.text}}
        </th>
        <td class="gt-query-total-column">
          {{serviceCall.totalDurationNanos / 1000000 | gtMillis}}
        </td>
        <td class="gt-query-count-column">
          {{serviceCall.executionCount | number}}
        </td>
        <td class="gt-query-other-column">
          {{serviceCall.timePerExecution | gtMillis}}
        </td>
      </tr>
      </tbody>
    </table>
  </div>
</div>
